package sz.szsmk.citizencard.model.network.bean.response;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * author : hyt
 * date : 2019/8/28
 * description :
 */
public class CalendarSignInRes  extends BaseBean implements Serializable{

    String credit;
    private List<SignCreditInfosBean> signCreditInfos;
    /**
     * rewardDate : {"date":"2019-08-31","credit":7,"configDay":3}
     */

    private RewardDateBean rewardDate;

    private String nowDate;

    public String getNowDate() {
        return nowDate;
    }

    public void setNowDate(String nowDate) {
        this.nowDate = nowDate;
    }

    public List<SignCreditInfosBean> getSignCreditInfos() {
        return signCreditInfos;
    }

    public void setSignCreditInfos(List<SignCreditInfosBean> signCreditInfos) {
        this.signCreditInfos = signCreditInfos;
    }

    public String getCredit() {
        return credit;
    }

    public void setCredit(String credit) {
        this.credit = credit;
    }

    public RewardDateBean getRewardDate() {
        return rewardDate;
    }

    public void setRewardDate(RewardDateBean rewardDate) {
        this.rewardDate = rewardDate;
    }

    public int getNowyyyy(){
        if(nowDate!=null){
            SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
            try {
                Date d = simpleDateFormat.parse(nowDate);
                Calendar cal = Calendar.getInstance();
                cal.setTime(d);
                return cal.get(Calendar.YEAR);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return 0;
    }
    public int getNowMM(){
        if(nowDate!=null){
            SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
            try {
                Date d = simpleDateFormat.parse(nowDate);
                Calendar cal = Calendar.getInstance();
                cal.setTime(d);
                return cal.get(Calendar.MONTH)+1;
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return 0;
    }
    public int getNowdd(){
        if(nowDate!=null){
            SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
            try {
                Date d = simpleDateFormat.parse(nowDate);
                Calendar cal = Calendar.getInstance();
                cal.setTime(d);
                return cal.get(Calendar.DATE);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return 0;
    }


    public static class SignCreditInfosBean {
        /**
         * date : 2019-08-28
         * credit : 7
         * configCredit : 1
         */

        private String date;
        private int credit;
        private int configCredit;

        public String getDate() {
            return date;
        }

        public void setDate(String date) {
            this.date = date;
        }

        public int getCredit() {
            return credit;
        }

        public void setCredit(int credit) {
            this.credit = credit;
        }

        public int getConfigCredit() {
            return configCredit;
        }

        public void setConfigCredit(int configCredit) {
            this.configCredit = configCredit;
        }

        public int getyyyy(){
            if(date!=null){
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
                try {
                    Date d = simpleDateFormat.parse(date);
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(d);
                    return cal.get(Calendar.YEAR);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
            return 0;
        }

        public int getMM(){
            if(date!=null){
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
                try {
                    Date d = simpleDateFormat.parse(date);
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(d);
                    return cal.get(Calendar.MONTH)+1;
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
            return 0;
        }
        public int getdd(){
            if(date!=null){
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
                try {
                    Date d = simpleDateFormat.parse(date);
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(d);
                    return cal.get(Calendar.DATE);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
            return 0;
        }
    }

    public static class RewardDateBean {
        /**
         * date : 2019-08-31
         * credit : 7
         * configDay : 3
         */

        private String date;
        @SerializedName("credit")
        private int creditX;
        private int configDay;

        public String getDate() {
            return date;
        }

        public void setDate(String date) {
            this.date = date;
        }

        public int getCreditX() {
            return creditX;
        }

        public void setCreditX(int creditX) {
            this.creditX = creditX;
        }

        public int getConfigDay() {
            return configDay;
        }

        public void setConfigDay(int configDay) {
            this.configDay = configDay;
        }

        public int getyyyy(){
            if(date!=null){
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
                try {
                    Date d = simpleDateFormat.parse(date);
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(d);
                    return cal.get(Calendar.YEAR);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
            return 0;
        }

        public int getMM(){
            if(date!=null){
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
                try {
                    Date d = simpleDateFormat.parse(date);
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(d);
                    return cal.get(Calendar.MONTH)+1;
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
            return 0;
        }
        public int getdd(){
            if(date!=null){
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
                try {
                    Date d = simpleDateFormat.parse(date);
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(d);
                    return cal.get(Calendar.DATE);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
            return 0;
        }
    }
}
